import java.util.Scanner;


public class CANDY {
	public static void main (String args[]) {
		Scanner in = new Scanner(System.in);
		int numCandy = in.nextInt();
		while (numCandy != -1) {
			int[] candyInPackets = new int[numCandy]; 
			int sum = 0;
			int moves = 0;
			for (int i = 0; i < numCandy; i++) {
				candyInPackets[i] = in.nextInt();
				sum += candyInPackets[i];
			}
			if ((sum % numCandy) == 0) {
				int avgCandy = sum / numCandy;
				for (int i = 0; i < numCandy; i++) {
					if (candyInPackets[i] > avgCandy) {
						moves += candyInPackets[i] - avgCandy;
					}
				}
				System.out.println(moves);
			} else {
				System.out.println(-1);
			}
			numCandy = in.nextInt();
		}
	}
}
